NET Link Tracker
Quick Start VB.NET

Create Expiring URL

Dim linkLogic As New LinkLogic() 'Trial Mode
Dim linkLogicLicensed As New LinkLogic("place user name here", "place license key here") 'License Mode
 
'Use a in memory mock database for testing
Dim databaseLogic As ILinkTrackerDatabaseLogic = New LinkTrackerMockDatabase()
 
linkLogic.DatabaseLogic = databaseLogic
 
'Create a link to a URL that will expire in 30 days
Dim createdLink As TrackedLink = linkLogic.CreateExpiringUrl("http://www.google.com", 30)
 
Dim link As TrackedLink = linkLogic.GetLinkByGuid(createdLink.LinkGuid)
Dim status As LinkStatus = linkLogic.CheckLinkStatus(link)
 
'The status will be Active
Console.WriteLine("Status: " & status)
 
'Get a friendly status for the user
Console.WriteLine("Friendly Status: " & linkLogic.GetFriendlyStatus(link))
 
'Force the link to expire
link.ExpirationDate = Date.Now.AddDays(-1)
databaseLogic.SaveTrackedLink(link)
 
status = linkLogic.CheckLinkStatus(link)
 
'The status will be Expired
Console.WriteLine("Status: " & status)
 
'Get a expired friendly status for the user
Console.WriteLine("Friendly Status: " & linkLogic.GetFriendlyStatus(link))
 
'Get the associated URL
Console.WriteLine("URL:  " & createdLink.FilePathOrUrl)
 
'This will perform a Response.Redirect
If HttpContext.Current IsNot Nothing Then 'This check not needed if running in ASP.NET process
    linkLogic.ProcessLink(createdLink)
End If

Create Expiring Download Link

Dim linkLogic As New LinkLogic() 'Trial Mode
Dim linkLogicLicensed As New LinkLogic("place user name here", "place license key here") 'License Mode
 
'Use a in memory mock database for testing
Dim databaseLogic As ILinkTrackerDatabaseLogic = New LinkTrackerMockDatabase()
 
linkLogic.DatabaseLogic = databaseLogic
 
'Create a dummy file for testing
Dim filePath As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test.txt")
File.WriteAllText(filePath,"This is a test")
 
'Create a link to a file that will expire in 30 days
Dim createdLink As TrackedLink = linkLogic.CreateExpiringDownload(filePath, 30)
 
Dim link As TrackedLink = linkLogic.GetLinkByGuid(createdLink.LinkGuid)
Dim status As LinkStatus = linkLogic.CheckLinkStatus(link)
 
'The status will be Active
Console.WriteLine("Status: " & status)
 
'Get a friendly status for the user
Console.WriteLine("Friendly Status: " & linkLogic.GetFriendlyStatus(link))
 
'Force the link to expire
link.ExpirationDate = Date.Now.AddDays(-1)
databaseLogic.SaveTrackedLink(link)
 
status = linkLogic.CheckLinkStatus(link)
 
'The status will be Expired
Console.WriteLine("Status: " & status)
 
'Get a expired friendly status for the user
Console.WriteLine("Friendly Status: " & linkLogic.GetFriendlyStatus(link))
 
'Get the associated File Path
Console.WriteLine("File Path:  " & createdLink.FilePathOrUrl)
 
'This will stream the file to the browser
If HttpContext.Current IsNot Nothing Then 'This check not needed if running in ASP.NET process
    linkLogic.ProcessLink(createdLink)
End If

Create Custom Link

Dim linkLogic As New LinkLogic() 'Trial Mode
Dim linkLogicLicensed As New LinkLogic("place user name here", "place license key here") 'License Mode
 
'Use a in memory mock database for testing
Dim databaseLogic As ILinkTrackerDatabaseLogic = New LinkTrackerMockDatabase()
 
linkLogic.DatabaseLogic = databaseLogic
 
'Create a dummy file for testing
Dim filePath As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test.txt")
File.WriteAllText(filePath, "This is a test")
 
'Create a link that expires 1 year from now, with a maximum of 10 IP Addresss, and a maximum of 2 requests per day
Dim parms As New LinkParms()
parms.IsUrl = False
parms.ExpirationDate = Date.Now.AddYears(1)
parms.MaxIpAddresses = 10
parms.MaxRequestsPerDay = 2
parms.FilePathOrUrl = filePath
 
Dim createdLink As TrackedLink = linkLogic.CreateLink(parms)
 
'Check the status
Dim link As TrackedLink = linkLogic.GetLinkByGuid(createdLink.LinkGuid)
Dim status As LinkStatus = linkLogic.CheckLinkStatus(link)
 
'The status will be Active
Console.WriteLine("Status: " & status)

'Get a friendly status for the user
Console.WriteLine("Friendly Status: " & linkLogic.GetFriendlyStatus(link))
 
'Force the link to expire
link.ExpirationDate = Date.Now.AddDays(-1)
databaseLogic.SaveTrackedLink(link)
 
status = linkLogic.CheckLinkStatus(link)
 
'The status will be Expired
Console.WriteLine("Status: " & status)
 
'Get a expired friendly status for the user
Console.WriteLine("Friendly Status: " & linkLogic.GetFriendlyStatus(link))
 
'Get the associated File Path
Console.WriteLine("File Path:  " & createdLink.FilePathOrUrl)
 
'This will stream the file to the browser
If HttpContext.Current IsNot Nothing Then 'This check not needed if running in ASP.NET process
    linkLogic.ProcessLink(createdLink)
End If